package com.chzc.sys.controller.pub;

import com.chzc.sys.service.IUserService;
import com.chzc.util.Result;
import com.chzc.vo.UserRegister;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author cv大魔王
 * @version 1.0
 * @date 2021/5/25 13:56
 */
@Api(value = "用户管理接口(公共)", tags = "用户管理接口(公共)")
@RestController
@RequestMapping("/pub/user")
public class PubUserController {

    @Autowired
    private IUserService userService;

    @ApiOperation("用户登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name="username", value="账号", required=true),
            @ApiImplicitParam(name="password", value="密码", required=true)
    })
    @GetMapping("/login/{username}/{password}")
    public Result doLogin(@PathVariable String username, @PathVariable String password) {
        return userService.login(username, password);
    }

    @ApiOperation("普通用户注册")
    @ApiImplicitParams({
            @ApiImplicitParam(name="username", value="账号", required=true),
            @ApiImplicitParam(name="password", value="密码", required=true)
    })
    @PostMapping("/register")
    public Result register(@RequestBody UserRegister user) {
        return userService.register(user);
    }



}
